<%@ page import="java.util.List" %>
<%@ page import="cn.edu.zut.model.User" %>
<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2019/6/13/013
  Time: 14:01
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<html>
<head>
    <title>用户管理</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="/js/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="/css/login.css"/>
    <script src="/js/jquery.min.js"></script>
    <script src="/js/bootstrap.min.js"></script>
    <script src="/js/bootstrap-table.min.css"></script>
    <script src="/js/bootstrap-table.min.js"></script>
    <style type="text/css">
        *{
            margin: 0;
            padding: 0;
        }
        body{
            background-color: white;
        }
        h1{
            background-color: aqua;
        }
        .label{
            background-color: #3BD9FF;
        }
        td{
            text-align: center;
        }
        table{

            background-color: white;
        }
    </style>
    <script>
        $(document).ready(function(){
            $("#table_page").bootstrapTable({
                columns:[{
                    field:'id',
                    title:'Id'
                },{
                    field:'Name',
                    title:'用户名'
                },{
                    field:'passWord',
                    title: '密码'
                },{
                    field:'Role',
                    title:'角色'
                },{
                    field:'option',
                    title:'操作'
                },],
                formatLoadingMessage:function () {
                    return "";
                },
            });
        });
    </script>
</head>
<body>
<h1 align="center">欢迎来到用户管理</h1>

<table class="table table-striped  table-bordered table-condensed" id="table_page"
       data-pagination="true"
       data-side-pagination="client"
       data-page-size="5">
    <%
       List<User> users= (List <User>)session.getAttribute("users");
        for (User user: users){
            out.println("<tr>");
            out.println("<td>"+user.getId()+"</td>");
            out.println("<td>"+user.getName()+"</td>");
            out.println("<td>"+user.getPasswd()+"</td>");
            if(user.getRole()==1){
                out.println("<td>"+"管理员"+"</td>");
            }
            else if(user.getRole()==0){
                out.println("<td>"+"普通用户"+"</td>");
            }
            else{
                out.println("<td>"+"未知用户"+"</td>");
            }
            out.println("<td><a href='/userDelete?name="+user.getName()+"'>删除</a> | <a href='/jsp/admin/modify.jsp?name="+user.getName()+"&id="+user.getId()+"'>修改</a></td>");
            out.println("</tr>");
        }
    %>
    </table>
<div class="alarm">
    <p style="color: white;text-align: center;font-size: 20px" > ${message }</p>
</div>
</body>
</html>
